package com.guoyihao.codesandbox.codesandbox;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 沙箱工厂
 */
@Component
@Slf4j
public class CodeSandBoxFactory {
    public static CodeSandBox getCodeSandBox(String language){
        CodeSandBox codeSandbox = null;
        switch (language){
            case "java":
                codeSandbox = new JavaDockerCodeSandBoxRunOnLinux();
                break;
            case "c++":
                codeSandbox = new CppDockerCodeSandBoxRunOnLinux();
            case "python":
                codeSandbox = new PythonDockerCodeSandBoxRunOnLinux();
        }
        if(codeSandbox == null){
            log.error("语言 {} 不支持",language);
            throw new RuntimeException("语言" + language + "不支持");
        }
        return codeSandbox;
    }
}
